package com.xy.task;

import com.xy.api.service.common.IUnitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ExchangeRateTask {

    @Autowired
    private IUnitService unitService;

    @Scheduled(cron = "corn.updateExchange:0 0 8 * * ?")
    public void updateExchangeRate() {
        log.info("enter task updateExchangeRate");
        try {
            unitService.updateExchangeRate();
        } catch (Exception ex) {
            log.error("task updateExchangeRate, error", ex);
        }
        log.info("out task updateExchangeRate");
    }
}
